package com.zhangjianling.premp.entity.sys;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 用户表
 * @author zhangjl
 *
 */

@Entity
@Table(name="SYS_USER")
@NoArgsConstructor
@AllArgsConstructor
public class SysUser implements Serializable{
	/**
	 *
	 */
	private static final long serialVersionUID = 1L;
	@Id
	@GeneratedValue(generator="system-uuid")
	@GenericGenerator(name="system-uuid", strategy="uuid.hex")
	@Column(name="USERID", nullable=false, length=50, scale=0)
	@Getter
	@Setter
	private String userId;

	@Column(name="USERNAME")
	@Getter
	@Setter
	private String userName;//用户名

	@Column(name="PASSWORD")
	@Getter
	@Setter
	private String password;//密码

	@Column(name="phone_num")
	@Getter
	@Setter
	private String phoneNum;//电话号码

	@Column(name="ROLENAME")
	@Getter
	@Setter
	private String roleName;//真实姓名

	@Column(name="REMARK")
	@Getter
	@Setter
	private String remark;//备注

	@Column(name="brithday")
	@Getter
	@Setter
	private String brithday;//出生日期

	@Column(name="sex")
	@Getter
	@Setter
	private String sex;//性别

	@Column(name="CREATETIME",updatable=false)
	@Getter
	@Setter
	private String createTime;

	@Column(name="UPDATETIME")
	@Getter
	@Setter
	private String updateTime;

	@Column(name="CREATEUSER",updatable=false)
	@Getter
	@Setter
	private String createUser;

	@Column(name="UPDATEUSER")
	@Getter
	@Setter
	private String updateUser;

	@Column(name="locked")
	@Getter
	@Setter
	private Boolean locked;//账号是否锁定

	@Column(name="is_visual")
	@Getter
	@Setter
	private String isVisual;//是否显示

	@Getter
	@Setter
	@ManyToMany(cascade = {CascadeType.REFRESH},fetch=FetchType.EAGER)
	@JoinTable(name = "user_role",joinColumns = { @JoinColumn(name = "userid", referencedColumnName = "userid") },inverseJoinColumns = { @JoinColumn(name = "roleid", referencedColumnName = "roleid") })
	private List<SysRole> roles = new ArrayList<SysRole>();

	@Getter
	@Setter
	@ManyToOne(cascade= {CascadeType.REFRESH,CascadeType.PERSIST},fetch = FetchType.EAGER)
	@JoinColumn(name="dept_id")
	private SysDept sysDept;

}
